<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="https://cdn.bootcdn.net/ajax/libs/vue/2.6.14/vue.common.dev.js"></script>
  <script src="http://api.tianditu.gov.cn/api?v=4.0&tk=ae735d13cbec178839eb32925ca76e7c"
    type="text/javascript"></script>
  <link href="__CDN__/assets/szxc/style/index.css" rel="stylesheet"/>
  <link href="__CDN__/assets/less/login.less" rel="stylesheet"/>
  <!-- 引入样式 -->
  <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
  <!-- 引入组件库 -->
  <script src="https://unpkg.com/element-ui/lib/index.js"></script>
</head>
<style>

.login {
  height: 100%;
  background: #f2f5f8;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login .cont-wrap {
  display: flex;
  width: 80%;
  height: 600px;
  background: #fff;
}
.login .cont-wrap .page-left {
  width: 60%;
  height: 100%;
  background: #f9f9f9;
}
.login .cont-wrap .page-left img {
  width: 100%;
  height: 100%;
}
.login .cont-wrap .page-right {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 40%;
}
.login .cont-wrap .page-right .demo-ruleForm {
  width: 400px;
}
.el-input__inner {
  border-color: transparent !important;
  border-bottom-color: #dcdfe6 !important;
}
.el-input__prefix {
  line-height: 30px;
}
.el-button {
  width: 100% !important;
  border-radius: 20px;
  background: #4d9ab0;
}

</style>
<body>
  <div id="app">
    <div class="login">
      <div class="cont-wrap">
        <div class="page-left"><img src="__CDN__/assets/szxc/assets/img/xx_login_bg.7d0956a5.png" /></div>
        <div class="page-right">
          <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
            <el-form-item prop="user">
              <el-input v-model.number="ruleForm.user" placeholder="请输入内容">
                <template slot="prefix"><i class="el-icon-user"></i></template>
              </el-input>
            </el-form-item>
            <el-form-item prop="pass">
              <el-input show-password type="password" v-model="ruleForm.pass" autocomplete="off" placeholder="请输入内容">
                <template slot="prefix"><i class="el-icon-lock"></i></template>
              </el-input>
            </el-form-item>
            <el-form-item>
              <el-button type="primary" @click="submitForm('ruleForm')">提交</el-button>
            </el-form-item>
          </el-form>
        </div>
      </div>
    </div>
  </div>
  <script type="module">
    var app = new Vue({
      el: '#app',
      data() {
        var checkUser = (rule, value, callback) => {
          if (!value) {
            return callback(new Error("用户名不能为空"));
          }
          setTimeout(() => {
            if (!Number.isInteger(value)) {
              callback();
            } else {
              callback();
            }
          }, 1000);
        };
        var validatePass = (rule, value, callback) => {
          if (value === "") {
            callback(new Error("请输入密码"));
          } else {
            callback();
          }
        };
        return {
          ruleForm: {
            pass: "",
            user: "",
          },
          rules: {
            pass: [{ validator: validatePass, trigger: "blur" }],
            user: [{ validator: checkUser, trigger: "blur" }],
          },
        };
      },
      methods: {
        submitForm(formName) {
          this.$refs[formName].validate((valid) => {
            if (valid) {
              this.$router.push('/home')
            } else {
              console.log("error submit!!");
              return false;
            }
          });
        },
        resetForm(formName) {
          this.$refs[formName].resetFields();
        },
      },
    })
  </script>
</body>

</html>